//
//  HistoryTableViewCell.m
//  Fangmm
//
//  Created by ChaoZhou on 16/3/25.
//  Copyright © 2016年 com.fangmm. All rights reserved.
//

#import "HistoryTableViewCell.h"
#import <UIButton+WebCache.h>
#import "Utility.h"
#import "Constants.h"
#import "Seat.h"
@implementation HistoryTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)configCellWithTeam:(Team*)team
{
    [self.houseImage sd_setBackgroundImageWithURL:[NSURL URLWithString:team.houseCover] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"Non_HP"]];
    self.joinTimeLabel.text = [NSString stringWithFormat:@"%@创建房间",team.createTime];
    self.houseNameLabel.text = team.houseCommunity;
    if ([team.leaderId isEqualToString:[Utility getObjectForKey:kUserId]])
    {
        self.maskLabel.text = @"室长";
    }
    else
    {
        self.maskLabel.text = @"室友";
    }
    switch (team.houseRoomNum)
    {
        case 1:
        {
            self.roomALabel.hidden = NO;
            self.roomBLabel.hidden = YES;
            self.roomCLabel.hidden = YES;
            self.roomAPrice.hidden = NO;
            self.roomBPrice.hidden = YES;
            self.roomCPrice.hidden = YES;
        }
            break;
        case 2:
        {
            self.roomALabel.hidden = NO;
            self.roomBLabel.hidden = NO;
            self.roomCLabel.hidden = YES;
            self.roomAPrice.hidden = NO;
            self.roomBPrice.hidden = NO;
            self.roomCPrice.hidden = YES;
        }
            break;
        case 3:
        {
            self.roomALabel.hidden = NO;
            self.roomBLabel.hidden = NO;
            self.roomCLabel.hidden = NO;
            self.roomAPrice.hidden = NO;
            self.roomBPrice.hidden = NO;
            self.roomCPrice.hidden = NO;
        }
            break;
        default:
        {
            self.roomALabel.hidden = YES;
            self.roomBLabel.hidden = YES;
            self.roomCLabel.hidden = YES;
            self.roomAPrice.hidden = YES;
            self.roomBPrice.hidden = YES;
            self.roomCPrice.hidden = YES;
        }
            break;
    }
    int joinNum = 0;
    for (int i = 0; i < team.seatArray.count; i ++)
    {
        Seat *seat = team.seatArray[i];
        switch (i)
        {
            case 0:
            {
                self.roomALabel.text = seat.roomName;
                self.roomAPrice.text = [NSString stringWithFormat:@"%d",seat.rent];
            }
                break;
            case 1:
            {
                self.roomBLabel.text = seat.roomName;
                self.roomBPrice.text = [NSString stringWithFormat:@"%d",seat.rent];
            }
                break;
            case 2:
            {
                self.roomCLabel.text = seat.roomName;
                self.roomCPrice.text = [NSString stringWithFormat:@"%d",seat.rent];
            }
                break;
            default:
                break;
        }
        if (seat.userId == nil || [seat.userId isEqualToString:@""])
        {
        }
        else
        {
            joinNum++;
        }
    }
    self.roommateNum.text = [NSString stringWithFormat:@"%d/%d",joinNum,team.houseRoomNum];
}

- (IBAction)roommateMenber:(UIButton *)sender
{
    [self.delegate queryRoommateWithSender:sender];
}

- (IBAction)houseImageClick:(UIButton *)sender
{
    
}
@end
